#include "stm32f10x.h"                  // Device header
#include "PWM.h"
#include "Delay.h"

uint8_t isOpen = 0;
uint16_t level = 0;

void Led_On(void) {
	if (!isOpen) {
		for(int i = 0; i <= 1000; i ++) {
			level = i;
			PWM_OutPut1_level(level);
			PWM_OutPut2_level(level);
			Delay_ms(1);
		}
		isOpen = 1;
	}
}

void Led_Off(void) {
	if (isOpen) {
		for(int i = 1000; i >= 0; i --) {
			level = i;
			PWM_OutPut1_level(level);
			PWM_OutPut2_level(level);
			Delay_ms(1);
		}
		isOpen = 0;
	}
}

void Led_Turn(void) {
	if (isOpen) {
		Led_Off();
	} else {
		Led_On();
	}
}

void Led_Init(void) {
	PWM_Init();
}
